package com.lagou.service.impl;

import com.lagou.dao.ResourceCategoryMapper;
import com.lagou.domain.ResourceCategory;
import com.lagou.service.ResourceCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ResourceCategoryServiceImpl implements ResourceCategoryService {

    @Autowired
    private ResourceCategoryMapper resourceCategoryMapper;

    /*查询资源分类信息*/
    @Override
    public List<ResourceCategory> findAllResourceCategory() {
        List<ResourceCategory> allResourceCategory = resourceCategoryMapper.findAllResourceCategory();
        return allResourceCategory;
    }

    /*添加资源分类*/
    @Override
    public void saveResourceCategory(ResourceCategory category) {
        //封装数据
        Date date = new Date();
        category.setCreatedTime(date);
        category.setUpdatedTime(date);
        category.setCreatedBy("system");
        category.setUpdatedBy("system");
        resourceCategoryMapper.saveResourceCategory(category);
    }

    /*修改资源分类*/
    @Override
    public void updateResourceCategory(ResourceCategory category) {
        //封装数据
        Date date = new Date();
        category.setUpdatedTime(date);
        category.setUpdatedBy("system");

        System.out.println(category);

        resourceCategoryMapper.updateResourceCategory(category);
    }

    /*删除资源分类*/
    @Override
    public void deleteResourceCategory(Integer id) {
        resourceCategoryMapper.deleteResourceCategory(id);
    }


}
